package net.pinnoocle.playshoppc.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.pinnoocle.playcommon.response.BaseResult;
import net.pinnoocle.playdao.entity.shopPc.TopScriptListVo;
import net.pinnoocle.playdao.entity.shopPc.homePage.HomePageStatisticsVo;
import net.pinnoocle.playdao.entity.shopPc.master.TopMasterListVo;
import net.pinnoocle.playdao.entity.shopPc.user.TopUserListVo;
import net.pinnoocle.playservice.service.impl.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author ye
 * @Description
 * @create 2021-11-13 11:16
 */
@RestController
@RequestMapping("/home")
@Api(tags = "首页")
public class HomePageController {

    @Autowired
    ScriptServiceImpl scriptService;
    @Autowired
    UserServiceImpl userService;
    @Autowired
    MasterServiceImpl masterService;
    @Autowired
    ShopServiceImpl shopService;
    @Autowired
    OrderServiceImpl orderService;

    @GetMapping("topScriptFive")
    @ApiOperation("剧本排行Top5")
    public BaseResult<List<TopScriptListVo>> topScriptFive(){
        return new BaseResult<List<TopScriptListVo>>().ok(scriptService.topScriptFive());
    }


    @GetMapping("topFiveUserList")
    @ApiOperation("店铺用户top5")
    public BaseResult<List<TopUserListVo>> topFiveUserList(){
        return new BaseResult<List<TopUserListVo>>().ok(userService.topFiveUserList());
    }

    @GetMapping("topFiveMaster")
    @ApiOperation("主持人热度排行")
    public BaseResult<List<TopMasterListVo>> topFiveMaster(){
        return new BaseResult<List<TopMasterListVo>>().ok(masterService.topFiveMaster());
    }

    @GetMapping("homePageStatistics")
    @ApiOperation("首页统计")
    public BaseResult<HomePageStatisticsVo> homePageStatistics(){
        return new BaseResult<HomePageStatisticsVo>().ok(shopService.homePageStatistics());
    }

    @GetMapping("orderTendencyChart")
    @ApiOperation("订单趋势图 type 0：本周 1：本月")
    public BaseResult<List<Map<String,Double>>> orderTendencyChart(@RequestParam("type") Integer type){
        return new BaseResult<List<Map<String,Double>>>().ok(orderService.orderTendencyChart(type));
    }
}
